<?php

namespace App\Http\Controllers;

use App\Models\ArticleModel;
use App\Models\ItemCateModel;
use Illuminate\Http\Request;

class WebsiteController extends Controller
{

    public function get_header(){

        $memus = ItemCateModel::where('pid', 5)->get(['name', 'id']);
        return view('layout.header')->with(compact('memus'));
    }

    public function index()
    {

        return view('index');
    }

    public function about()
    {
        $content = ArticleModel::where('cate_id', 1)->first();
        return view('about')->with(compact('content'));
    }

    public function service(Request $request)
    {
        $categories = ItemCateModel::where('pid', 2)->get(['name', 'id']);

        $content = ArticleModel::where('cate_id', $request->id)->first();
        return view('service')->with(compact('categories','content'));
    }

    public function news()
    {
        /*分类*/
        $categories = ItemCateModel::where('pid', 5)->get(['name', 'id']);
        /*新闻列表*/
        $articleContents = ArticleModel::where('cate_id',6)->orwhere('cate_id',7)->get();
//        dd($articleContents);


        return view('news')->with(compact('categories','articleContents'));
    }




    public function view(Request $request)
    {
        $categories = ItemCateModel::where('pid', 5)->get(['name', 'id']);

        $content = ArticleModel::where('cate_id', $request->id)->first();

        return view('view')->with(compact('categories', 'content'));
    }


    public function partners()
    {

        return view('partners');
    }

    public function contact()
    {

        return view('contact');
    }
}
